package Eve.EveB;

class WordLink implements Comparable{
	public String word;
	public int frequency;

	WordLink(int frequency, String word){
		this.word= word;
		this.frequency=frequency;
	}

	public String toString(){
		return this.word+"("+this.frequency+")";
	}

	public int compareTo(Object o){
		if(o!=null && o instanceof WordLink){
			WordLink wl = ((WordLink)o);
			if(this.frequency-wl.frequency!=0) return this.frequency-wl.frequency;
			return (-1)*this.word.compareTo(wl.word);
		}
		return 1;
	}

	public boolean equals(Object o){
        return o != null && o instanceof WordLink && compareTo(o) == 0;
    }

    public static WordLink max(WordLink wl1, WordLink wl2){
        if(wl1==null && wl2==null) return null;
        if(wl2==null) return wl1;
        if(wl1==null) return wl2;
        if(wl1.compareTo(wl2)>0) return wl1;
        return wl2;
    }
}